package com.efuture.chaptertow

/* @Description:演示kotlin 函数引用
 * @Auther: zhaoshanshan
 * @Date: 2022/03/04/9:26 下午
 */
fun main() {

    //lambda 属于函数类型的对象 需要把methodResult普通函数变成函数类型对象(函数引用)
    //login("zhaoshanshan","123456",::methodResult);
    val obj = ::methodResult
    login("zhaoshanshan","123456",obj);

}
fun methodResult(msg:String,code:Int){
    println("msg:$msg,code:$code")
}
inline fun login(userName:String,pwd:String,result:(String,Int)->Unit){
    if(userName=="zhaoshanshan"&&pwd=="123456"){
        result("登录成功",200);
    }else{
        result("登录失败",400);
    }
}